/**
 * Created by Toma on 2016/12/15.
 */

/**
 * 解析URL参数
 * @example ?id=123456&a=b
 * @return Object {id:132,a:b}
 */
export function urlParse() {
  "use strict";
  let url = window.location.search;
  let obj = {};
  let reg = /[?&][^?&]+=[^?&]+/g;
  let arr = url.match(reg);

  if (arr) {
    arr.forEach(item => {
      let tempArr = item.substring(1).split('=');
      let key = decodeURIComponent(tempArr[0]);
      let val = decodeURIComponent(tempArr[1]);
      obj[key] = val;
    });
  }
  
  return obj;
};
